

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Fly542">
  <meta name="keywords" content="">
  
    <meta name="description" content="翻译自《https:&#x2F;&#x2F;www.snoyman.com&#x2F;blog&#x2F;2020&#x2F;05&#x2F;no-mutable-parameters-in-rust》 在回顾Begin Rust书中的倒数第二章时，出现了一个稍微高级的话题。这个话题引起了我一段时间的兴趣，特别是因为它展示了Rust和Haskell如何处理可变性的一些根本差异。该主题对于本书而言太高了，但是我想提供一个外部资源，以供有好奇心的人参考。就是这">
<meta property="og:type" content="article">
<meta property="og:title" content="为什么函数参数提示《remove this mut》">
<meta property="og:url" content="http://fly542.cn/2020/07/26/03%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/02Rust/%E4%B8%BA%E4%BB%80%E4%B9%88%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0%E6%8F%90%E7%A4%BAremovte_this_mut/index.html">
<meta property="og:site_name" content="Fly542 技术沉淀">
<meta property="og:description" content="翻译自《https:&#x2F;&#x2F;www.snoyman.com&#x2F;blog&#x2F;2020&#x2F;05&#x2F;no-mutable-parameters-in-rust》 在回顾Begin Rust书中的倒数第二章时，出现了一个稍微高级的话题。这个话题引起了我一段时间的兴趣，特别是因为它展示了Rust和Haskell如何处理可变性的一些根本差异。该主题对于本书而言太高了，但是我想提供一个外部资源，以供有好奇心的人参考。就是这">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-07-26T09:28:11.000Z">
<meta property="article:modified_time" content="2022-12-30T03:33:01.383Z">
<meta property="article:author" content="Fly542">
<meta property="article:tag" content="rust">
<meta name="twitter:card" content="summary_large_image">
  
  
  <title>为什么函数参数提示《remove this mut》 - Fly542 技术沉淀</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hint.css@2/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"fly542.cn","root":"/","version":"1.8.14","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 6.0.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fly542 技术沉淀</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="为什么函数参数提示《remove this mut》">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2020-07-26 17:28" pubdate>
        2020年7月26日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      2.8k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      24 分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">为什么函数参数提示《remove this mut》</h1>
            
            <div class="markdown-body">
              <p>翻译自《<a target="_blank" rel="noopener" href="https://www.snoyman.com/blog/2020/05/no-mutable-parameters-in-rust%E3%80%8B">https://www.snoyman.com/blog/2020/05/no-mutable-parameters-in-rust》</a></p>
<p>在回顾Begin Rust书中的倒数第二章时，出现了一个稍微高级的话题。这个话题引起了我一段时间的兴趣，特别是因为它展示了Rust和Haskell如何处理可变性的一些根本差异。该主题对于本书而言太高了，但是我想提供一个外部资源，以供有好奇心的人参考。就是这里！</p>
<p>让我们逐步构建它。以下程序可以编译吗？</p>
<figure class="highlight sas"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></div></td><td class="code"><pre><code class="hljs sas">fn ma<span class="hljs-meta">in(</span>) &#123;<br>    let <span class="hljs-meta">x</span> = 5;<br>    <span class="hljs-meta">x</span> += 1;<br>    println!(<span class="hljs-string">&quot;x == &#123;&#125;&quot;</span>, <span class="hljs-meta">x</span>);<br>&#125;<br></code></pre></td></tr></table></figure>
<p>答：不！x是一个不可变的变量，因此不能+= 1在其上使用。解决这个问题很容易：add mut：</p>
<figure class="highlight rust"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() &#123;<br>    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> x = <span class="hljs-number">5</span>;<br>    x += <span class="hljs-number">1</span>;<br>    <span class="hljs-built_in">println!</span>(<span class="hljs-string">&quot;x == &#123;&#125;&quot;</span>, x);<br>&#125;<br></code></pre></td></tr></table></figure>
<p>但是由于加1和打印在我的应用程序中是如此重要（是的，这很讽刺），所以我决定将其提取为自己的函数。告诉我，这段代码可以编译吗？</p>
<figure class="highlight llvm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs llvm">fn add_and_print(<span class="hljs-keyword">x</span>: <span class="hljs-type">i32</span>) &#123;<br>    <span class="hljs-keyword">x</span> +<span class="hljs-operator">=</span> <span class="hljs-number">1</span><span class="hljs-comment">;</span><br>    println!(<span class="hljs-string">&quot;x == &#123;&#125;&quot;</span><span class="hljs-punctuation">,</span> <span class="hljs-keyword">x</span>)<span class="hljs-comment">;</span><br>&#125;<br></code></pre></td></tr></table></figure>
<p>不，并且出于与第一个示例相同的原因：x是不可变的。修复也很容易：</p>
<figure class="highlight llvm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs llvm">fn add_and_print(mut <span class="hljs-keyword">x</span>: <span class="hljs-type">i32</span>) &#123;<br>    <span class="hljs-keyword">x</span> +<span class="hljs-operator">=</span> <span class="hljs-number">1</span><span class="hljs-comment">;</span><br>    println!(<span class="hljs-string">&quot;x == &#123;&#125;&quot;</span><span class="hljs-punctuation">,</span> <span class="hljs-keyword">x</span>)<span class="hljs-comment">;</span><br>&#125;<br></code></pre></td></tr></table></figure>
<p>现在，我们的函数<code>add_and_print</code>拥有唯一的参数x,它的类型是i32，并且是可变的。嗯不错。最后，我们可以在  <code>main    </code>中调用此函数。告诉我，该程序可以编译并运行吗？是否和预想的一样没有任何警告吗？</p>
<figure class="highlight sas"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs sas">fn ma<span class="hljs-meta">in(</span>) &#123;<br>    let mut <span class="hljs-meta">x</span> = 5;<br>    add_and_p<span class="hljs-meta">rint(</span><span class="hljs-meta">x</span>);<br>&#125;<br><br>fn add_and_p<span class="hljs-meta">rint(</span>mut <span class="hljs-meta">x</span>: i32) &#123;<br>    <span class="hljs-meta">x</span> += 1;<br>    println!(<span class="hljs-string">&quot;x == &#123;&#125;&quot;</span>, <span class="hljs-meta">x</span>);<br>&#125;<br></code></pre></td></tr></table></figure>
<p>答：它会编译，运行并生成输出x == 6。但是，它确实有一个警告：</p>
<figure class="highlight gherkin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs gherkin">warning: variable does not need to be mutable<br> --&gt; src/main.rs:2:9<br>  |<span class="hljs-string"></span><br><span class="hljs-string">2 </span>|<span class="hljs-string">     let mut x = 5;</span><br><span class="hljs-string">  </span>|<span class="hljs-string">         ----^</span><br><span class="hljs-string">  </span>|<span class="hljs-string">         </span>|<br>  |<span class="hljs-string">         help: remove this `mut`</span><br><span class="hljs-string">  </span>|<br></code></pre></td></tr></table></figure>
<p>最初，至少对于我来说，这确实令人惊讶。<code>add_and_prin</code>t需要接收一个可变变量i32作为其第一个参数。我们为其提供了可变的i32。然后编译器说<code>mut</code>在 <code>main</code>中是不必要的。这是什么情况？</p>
<p>我上面的解释有一个错误。函数<code>add_and_print</code>，可能非常令人困惑，不用将可变变量i32作为参数。“但是前面说需要mut的！！！”，而现在又说mut是不必要的。 确实如此。mut详细信息位于函数内部，而不是其类型签名的一部分。这听起来令人困惑，所以让我解释一下。</p>
<p>在Rust中有一个模式，我称之为rust的3条规则。这涵盖了以下事实：在许多情况下，我们最终会得到三个“版本”的事物：</p>
<figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs mipsasm">An immutable <span class="hljs-keyword">borrow </span>  <span class="hljs-comment"># 不可变借用</span><br>A mutable <span class="hljs-keyword">borrow </span> <span class="hljs-comment"># 可变借用</span><br>A <span class="hljs-keyword">move </span> <span class="hljs-comment"># 移动</span><br></code></pre></td></tr></table></figure>
<p>这可以应用于函数参数，例如：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs php"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">immutable_borrow</span>(<span class="hljs-params">x: &amp;<span class="hljs-keyword">String</span></span>)</span><br><span class="hljs-function"><span class="hljs-title">fn</span> <span class="hljs-title">mutable_borrow</span>(<span class="hljs-params">x: &amp;mut <span class="hljs-keyword">String</span></span>)</span><br><span class="hljs-function"><span class="hljs-title">fn</span> <span class="hljs-title">move</span>(<span class="hljs-params">x: <span class="hljs-keyword">String</span></span>)</span><br></code></pre></td></tr></table></figure>
<p>请注意，差异完全在冒号之后。冒号后的内容是3个不同的<code>类型</code>，而<code>类型</code>构成了<code>函数签名</code>。</p>
<p>但是，示例中的<code>x</code>冒号前的内容对<code>函数签名</code>没有影响。<code>变量名称</code>与函数的签名无关。一旦冒号右边传递一个<code>值</code>函数即可决定要调用的内容。</p>
<p>此规则不仅适用于变量名称。也适用于<code>可变变量</code>。<code>mutable</code>是rust中<code>变量</code>的一个feature而不是<code>值</code>的feature。当使用let mut x = 5时，表示的是 “创建一个叫x的<code>变量</code>，它指向一个<code>值</code>5，并且允许用x来对该<code>值</code>进行改变。” 如果没有mut，将不再被允许通过<code>变量</code>x对该<code>值</code>进行改变。</p>
<p>您可能会有一个直觉的反应，如果您无法修改<code>变量</code>，那你就只能只读它了。一般直觉应该就是这样。但Rust中并非如此。您还可以做另一件事：将<code>值</code>移到另一个作用域。<code>add_and_print</code>通过<code>move</code>接受<code>值</code>，即使x是一个不可变的<code>变量</code>，我仍然可以移动它所指向的<code>值</code>。</p>
<p>一旦移动了<code>值</code>，那就完全取决于<code>add_and_print</code>如何处理它。即使原始<code>变量</code>是不可变的，也可以将其变为可变的。这是因为在函数调用中<code>值</code>本身被传递过来，而不是变量。而值可以根据需要来变为可变的。</p>
<p>因此，该程序的无警告版本为：</p>
<figure class="highlight sas"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs sas">fn ma<span class="hljs-meta">in(</span>) &#123;<br>    let <span class="hljs-meta">x</span> = 5;<br>    add_and_p<span class="hljs-meta">rint(</span><span class="hljs-meta">x</span>);<br>&#125;<br><br>fn add_and_p<span class="hljs-meta">rint(</span>mut <span class="hljs-meta">x</span>: i32) &#123;<br>    <span class="hljs-meta">x</span> += 1;<br>    println!(<span class="hljs-string">&quot;x == &#123;&#125;&quot;</span>, <span class="hljs-meta">x</span>);<br>&#125;<br></code></pre></td></tr></table></figure>
<p>实际上，即使没有函数调用，move后为可变的也是可能发生的。例如，您可以在单个函数中将不可变变量“升级”为可变变量：</p>
<figure class="highlight rust"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() &#123;<br>    <span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;<br>    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> y = x;<br>    y += <span class="hljs-number">1</span>;<br>    <span class="hljs-built_in">println!</span>(<span class="hljs-string">&quot;y == &#123;&#125;&quot;</span>, y);<br>&#125;<br></code></pre></td></tr></table></figure>
<p>“等一下” 您抱怨道，“你不能将不可变的引用“升级”为可变的引用！” ，对于我的解释或许还有其他类似的关于抱怨。我在这里稍加修饰的是: 当涉及到引用时，可变性被转化为值的可变性。那是因为对于类似x: &amp;i32这种形式的引用，x自身并没有任何数值，它<code>引用</code>了一个数字。对于可变或不可变是对<code>引用</code>本身来说的，因为<code>引用</code>自身是一种类型。因此，您不能简单地将不可变引用升级为可变引用。此代码已损坏：</p>
<figure class="highlight rust"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() &#123;<br>    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> x: <span class="hljs-built_in">i32</span> = <span class="hljs-number">5</span>;<br>    <span class="hljs-keyword">let</span> y: &amp;<span class="hljs-built_in">i32</span> = &amp;x;<br>    <span class="hljs-keyword">let</span> z: &amp;<span class="hljs-keyword">mut</span> <span class="hljs-built_in">i32</span> = y; <span class="hljs-comment">// 不能简单的将y升级为可变的</span><br><br>    *z += <span class="hljs-number">1</span>;<br><br>    <span class="hljs-built_in">println!</span>(<span class="hljs-string">&quot;x == &#123;&#125;&quot;</span>, x);<br>&#125;<br></code></pre></td></tr></table></figure>
<p>因此，总结一下：</p>
<ul>
<li>您可以拥有<code>值</code>，或<code>值</code>的<code>不变引用</code>或<code>值</code>的<code>可变引用</code></li>
<li><code>值</code>只有2种状态，要么可变的，要么不可变</li>
<li>相似的<code>变量</code>也只有2种状态，要么可变的，要么不可变</li>
<li>当将<code>值</code>移动到新<code>变量</code>中（通过 let或函数调用）时，可以更改<code>变量</code>的可变性</li>
<li>函数签名中<code>变量</code>的可变性和名称并不影响函数签名</li>
<li>引用的可变性内置在类型本身中，因此您不能将不可变的引用“升级”为可变的引用</li>
</ul>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/">软件开发</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/rust/">rust</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2020/07/26/03%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/01c_cpp/02%E5%A4%A7%E7%AB%AF-%E5%B0%8F%E7%AB%AF%E5%AF%B9%E9%BD%90%E5%88%A4%E5%AE%9A%E5%87%BD%E6%95%B0/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">大端-小端对齐判定函数</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2020/07/25/03%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/03linux/07linux%E4%B8%8BIO%E5%BA%94%E7%94%A8%E8%AF%A6%E8%A7%A3/">
                        <span class="hidden-mobile">linux下IO应用详解</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
